﻿using IT_RoadBlock.Dto;
using IT_RoadBlock.Handlers;
using System;
using System.Windows.Input;

namespace IT_RoadBlock.Comands
{
    /// <summary>
    /// 列表通用命令
    /// </summary>
    public abstract class EditRelayCommand<T>: IWindowClose
    {

        private T curData;
        /// <summary>
        /// 主体数据
        /// </summary>
        public T CurData
        {
            get => curData; set
            {
                curData = value;
                OnPropertyChanged(nameof(CurData));
            }
        }


        /// <summary>
        /// 保存
        /// </summary>
        public ICommand SaveItemCmd
        {
            get
            {
                return new RelayCommand<T>(SaveItemCmdExecute, CanSaveItemCmdExecute);
            }
        }
        protected bool CanSaveItemCmdExecute()
        {
            return true;
        }


        protected abstract void SaveItemCmdExecute(T obj);

      
    }
}
